<template>

    <div>
        <!--<v-app-bar>
        <v-btn to="/home"  color="dark" white>home</v-btn>  预约挂号
        <v-spacer></v-spacer>
    </v-app-bar>-->
        <HomeHeader  :type_="type_"></HomeHeader>
       <v-content>
           <v-container>
            <v-card>
                <v-toolbar flat color="primary" dark>
                    <v-toolbar-title>选择医生</v-toolbar-title>
                </v-toolbar>
                <v-tabs vertical>
                    <v-tab v-for="(item, i) in getdata" :key="i">{{item.dep_name}}
                    </v-tab>
                    <v-tab-item v-for="(item,i) in getdata" :key="i">
                        <v-card flat>
                               <v-btn  color="primary" dark @click="_orderwin(datatwo[i].doctors[j],item.dep_name,item2)" v-for="(item2,j) in item.doctors" :key="j">{{item2}}</v-btn>
                        </v-card>
                    </v-tab-item>
                </v-tabs>
            </v-card>
               <v-dialog v-model="show" max-width="500px">
                   <v-card>
                       <v-card-title>
                           <span class="headline">{{dep_name}}:{{doc_name}}</span>
                       </v-card-title>
                       <v-card-text>
                           <v-container>
                               <v-row>
                                   <v-col cols="12" sm="6" md="4">
                                       <v-btn color="blue darken-1" text @click="_order(item.app_id,item.app_time)" v-for="(item,i) in getdatawin" :key="i">{{item.app_date}}:{{item.app_time}}</v-btn>
                                   </v-col>
                               </v-row>
                           </v-container>
                       </v-card-text>
                       <v-card-actions>
                           <v-spacer></v-spacer>
                           <v-btn color="blue darken-1" text @click="show=!show">取消</v-btn>
                            </v-card-actions>
                   </v-card>
               </v-dialog>
           </v-container>
        </v-content>
    </div>
</template>
<script>
export default {
  name:"Home",
  data(){
    return{
        type_:'use',
        show:false,
        dep_name:'',
        doc_name:'',
      todos:[],
      swiper:[],
        selection: [],
        items: [
            { text: '产科', icon: 'mdi-folder',address:'' },
      { text: '创伤骨科', icon: 'mdi-account-multiple',address:'' },
      { text: '口鼻喉科', icon: 'mdi-star',address:'' },
      { text: '儿科', icon: 'mdi-history' ,address:''},
      { text: '妇科', icon: 'mdi-check-circle',address:'' }
  ],
        getdata:[],
        datatwo:[],
      getdatawin:[]
    }
  },
methods:{
      _orderwin(doc_id,dep_name,doc_name){
          this.dep_name=dep_name
          this.doc_name=doc_name
          this.show=!this.show
          var params ={
          doc_id:doc_id,
          _option:'2017'
          }
          this.$http.post(params,2).then((res)=>{
              let { resultCode, resultObject, resultMsg } = res
              if (resultCode === '0') {
                  if (resultObject) {
                      this.getdatawin = resultObject.dataList
                  } else {
                      this.getdatawin = []
                  }
              } else {
                  this.getdatawin = []
                  this.response=resultMsg
              }
          })
      },
    _order(app_id,ord_time){
        var x = this.getCookie('username')
        var params ={
            app_id:app_id,
            ord_time:ord_time,
            use_id:x,
            _option:'2006'
        }
        this.$http.post(params,2).then((res)=>{
            let { resultCode, resultObject, resultMsg } = res
            if (resultCode === '0') {
                if (resultObject) {
                    this.getdatawin = resultObject.dataList
                } else {
                    this.getdatawin = []
                }
            } else {
                this.getdatawin = []
                this.response=resultMsg
            }
        })
        this.show=!this.show
    },
    getCookie(cname){
        var name = cname + "=";
        var ca = document.cookie.split(';')
        for(var i=0; i<ca.length; i++)
        {
            var c = ca[i].trim();
            if (c.indexOf(name)==0) return c.substring(name.length,c.length)
        }
        return "";
    },
    _begin(){
        var params ={_option:'2016'}
        this.$http.post(params,2).then((res)=>{
            let { resultCode, resultObject, resultMsg } = res
            if (resultCode === '0') {
                if (resultObject) {
                    this.getdata = resultObject.dataList
                    this.datatwo = resultObject.dataListTwo
                } else {
                    this.getdata = []
                    this.datatwo = []
                }
            } else {
                this.getdata = []
                this.datatwo = []
                this.response=resultMsg
            }
        })
    }
},
  computed:{
      
  },mounted(){
       this._begin()
    }
}
</script>

<style scoped>

</style>

